package com.cskaoyan.controller;


import com.cskaoyan.bean.Issue;
import com.cskaoyan.bo.IssueCreateBO;
import com.cskaoyan.service.CommonService;
import com.cskaoyan.vo.BaseRespVo;
import com.cskaoyan.vo.IssueListVO;
import com.cskaoyan.vo.IssueVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class CommonController {

    @Autowired
    CommonService commonService;

    @RequestMapping("admin/issue/list")

    public BaseRespVo queryIssue(Integer page, Integer limit, String question, String sort, String order) {

        IssueVO issueVO = commonService.queryIssue(page, limit, question, sort, order);
        return BaseRespVo.ok(issueVO);
    }
    @RequestMapping("admin/issue/delete")

    public BaseRespVo issueDelete(@RequestBody Issue issue){

        commonService.issueDelete(issue);

        return BaseRespVo.ok();
    }
    @RequestMapping("admin/issue/update")
    public BaseRespVo issueUpdate(@RequestBody Issue issue){

        Issue issues=commonService.issueUpdate(issue);

        return BaseRespVo.ok(issue);
    }
    @RequestMapping("admin/issue/create")
    public BaseRespVo create(@RequestBody IssueCreateBO issueCreateBO){
        IssueListVO.ItemsBean itemsBean = commonService.create(issueCreateBO);
        return BaseRespVo.ok(itemsBean);
    }
}
